<?php
$params = array_merge(
    require __DIR__ . '/../../common/config/params.php',
    require __DIR__ . '/../../common/config/params-local.php',
    require __DIR__ . '/params.php'
);

return [
    'id' => 'app-backend',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'backend\controllers',
    'bootstrap' => ['log'],
    'defaultRoute' => 'site/index',  //todo
    'modules' => [],
    'components' => [
        'response'=>[
            'on beforeSend' => function ($event) {
                $event->sender->headers->add('Access-Control-Allow-Origin', '*');
            },
        ],
        'request' => [
            'csrfParam' => '_csrf-backend',
            'cookieValidationKey' => 'asdfgh123456',
        ],
        'user' => [
            'class' => 'common\component\WebUser',
            'loginDuration' => 7200, //登录默认时间
            'userType' => \common\component\WebUser::USER_BACKEND,
            'identityClass' => 'common/models/user',
            'enableAutoLogin' => true
        ],
        'session' => [
            'class' => 'yii\web\Session',
            // this is the name of the session cookie used for login on the backend
               'timeout'=>7200,
                  'name'=>'BSESSID',
            'cookieParams' => [
                'domain' => '/',
                'secure' => false,
                'httponly'=>true,
            ],
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],

        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => require(__DIR__ . "/new_rules.php"), //todo
        ],
    ],
    'params' => $params,
];
